<template>
	<view>
		<view class="shoplist-box">
			<view class="shoplist-item" v-for="(item,index) in shoplist" :key="index" @click="choiceShop(item);">
				<view class="left-img">
					<image src="/static/images/shop_logo.png"></image>
				</view>
				<view class="right-text">
					{{item.shopName}}
				</view>
			</view>
			
		</view>
	</view>
</template>

<script>
	import avatar from "../../components/yq-avatar/yq-avatar.vue";
	const util = require("../../utils/util.js");
	//获取应用实例
	const api = require("../../config/api.js");
	export default {
		data() {
			 return {
				shoplist:''
			}
		},
		components: {
		            avatar
		},
		onLoad(){
			var _that = this;
			_that.getShopList();
			uni.setStorageSync('isGetShopInforStorage',false);
			
			
		},
		methods: {
			getShopList(){
				var _that= this;
				
				console.log("请求函数");
				uni.getLocation({
				    type: 'gcj02', //返回可以用于uni.openLocation的经纬度
				    success: function (res) {
						console.log('res',res);
						var data = new Object();
						data.latitude = res.latitude;
						data.longitude = res.longitude;
				        util.request(api.nearbyMerUsers,data, 'POST').then(res => {
							console.log("接口返回",res);
				        	if(res.error==0){
								_that.shoplist = res.data;
							}	
				        			
				        })
				    }
				});
			},
			choiceShop(obj){
				console.log("")
				var _that= this;
				console.log(obj);
				// 是否获取商铺信息缓存
				uni.setStorageSync('isGetShopInforStorage',true);
				uni.setStorageSync('putShopInfor',obj);
				
				
			
			  uni.navigateBack({  //uni.navigateTo跳转的返回，默认1为返回上一级
				delta: 1
			  });
				
				
			}
			

		}
	}
</script>

<style>
	@import url("./shopList.css");
</style>
